<?php
load_theme_textdomain('NeeWee');
$config_folder = TEMPLATEPATH . '/config/';
$config_file_path = TEMPLATEPATH . '/config/config.' . preg_replace("/^www\./", '', $_SERVER['SERVER_NAME']) . '.txt'; 

$use_db = false;

if(!is_writable($config_folder)) {
	if(!chmod($config_folder, 666)) {
		$use_db = true;
	}
}

if(!$use_db && (!function_exists('file_put_contents') || !function_exists('file_get_contents'))) {
	$use_db = true;
}

if(!$use_db && !file_exists($config_file_path)) {
	file_put_contents($config_file_path, '');
}

$default_settings = Array(
	'adsense_publisher_id' => '',
	'analytics_id' => '',
	'featured_category' => -1,
	'feedburner_name' => '',
	'feedburner_feed_url' => '',
	'feedburner_email_id' => '',
	'feedburner_stats' => 0,
	'color_scheme' => 'blue'
);


if (!is_array(get_option('neewee'))) {
	add_option('neewee', $default_settings);
}

if ( function_exists('register_sidebar') ) {
	register_sidebar(array('name'=>'sidebar1',
	'before_widget' => '<div class="widget">',
	'after_widget' => '</div>',
	'before_title' => '<h4>',
	'after_title' => '</h4>',
	));
	
	register_sidebar(array('name'=>'sidebar2',
	'before_widget' => '<div class="widget">',
	'after_widget' => '</div>',
	'before_title' => '<h4>',
	'after_title' => '</h4>',
	));
}

if(is_admin()) {
	require_once(TEMPLATEPATH . '/admin/interface.php');
	$admin = new AdminInterface($config_file_path);
}
?>